local hj_lieqi = fk.CreateSkill {
  name = "hj_lieqi",
  tags = { Skill.Compulsory, },
}

local WU = require "packages/wdtx/WUltiity"

hj_lieqi:addEffect(fk.EventPhaseStart, {
  anim_type = "support",
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(hj_lieqi.name) or target ~= player then return end
    return player.phase == Player.Play and player:usedSkillTimes(hj_lieqi.name, Player.HistoryTurn) == 0 and table.find(player:getCardIds("he"),function(cid) return Fk:getCardById(cid).type == Card.TypeTrick end)
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local tricks = table.filter(player:getCardIds("he"),function(cid) return Fk:getCardById(cid).type == Card.TypeTrick end)
    local discs = math.ceil(#tricks * 1.5)
    room:throwCard(tricks, hj_lieqi.name, player, player)
    WU:checkCards(player,".|.|.|.|.|^trick",discs)
  end,
})
hj_lieqi:addEffect(fk.TargetSpecifying, {
  anim_type = "support",
  can_trigger = function(self, event, target, player, data)
    if not player:hasSkill(hj_lieqi.name) or target ~= player then return end
    return data.card.trueName == "slash" and player:distanceTo(data.to) == 1
  end,
  on_use = function(self, event, target, player, data)
    data.disresponsive = true
  end,
})

hj_lieqi:addEffect("distance", {
  name = "#hj_lieqi_dis",
  correct_func = function(self, from, to)
    if from:hasSkill(hj_lieqi.name) then
      return -1
    end
  end,
})

return hj_lieqi